package com.lysj.admin.utils.spring.foundation.configuration;

import com.lysj.admin.utils.resolver.UserIdResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.lysj.admin.utils.validation.ValidatorResolver;

import java.util.List;

/**
 * @author Created by zk on 2018-12-13 10:43
 * @description 配置参数解析器
 */
@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

//    @Override
//    protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
//        argumentResolvers.add(validatorResolver());
//        super.addArgumentResolvers(argumentResolvers);
//    }


    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(validatorResolver());
        argumentResolvers.add(userIdResolver());
        super.addArgumentResolvers(argumentResolvers);
    }

    @Bean
    public ValidatorResolver validatorResolver(){
        return new ValidatorResolver();
    }

    @Bean
    public UserIdResolver userIdResolver(){return new UserIdResolver();}

}
